{% extends 'search_result.html' %}
{% block page_title %}Community{% endblock page_title %}
{% block navbar_status %}
<li class="active"><a href="#">社区 <span class="sr-only">(current)</span></a></li>
<li><a type="submit" href="/community/question/?q=11" target="_blank">Github</a></li>
{% endblock navbar_status %}
{% block main_div %}
<div class="col-md-12">
    <div class="page-header">
        <h1>社区 <small>你参加的讨论组</small></h1>
    </div>
</div>
<div class="col-md-12">
{% if errormsg != None %}
<div class="alert alert-danger alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>ERROR:</strong> {{ errormsg }}
</div>
{% elif msg != None %}
<div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>Message:</strong> {{ msg }}
</div>  
{% endif %}
</div>

<div class="col-md-12">
<table class="table">
    {% for eachgroup in user.group %}
    <tr>
    {% if eachgroup == groupname %}
    <td style="width: 80%;">
        <div class="panel panel-primary">
            <div class="panel-heading text-capitalize">{{ eachgroup }} Channel <div class="navbar-right"><a href="/community/newquestion/?gname={{ eachgroup }}" style="color: white; margin-right: 20px;">New Question <span class="glyphicon glyphicon-plus"></span></a></div></div>
            <div class="panel-body list-group">
                {% for eachquestion in questions %}
                    <a href="/community/question/?q={{ eachquestion.id }}&gname={{ groupname }}" class="list-group-item {% if eachquestion.status == None %}
                    {% elif eachquestion.status == 1 %}
                        list-group-item-success
                    {% elif eachquestion.status == 2 %}
                        list-group-item-info    
                    {% elif eachquestion.status == 3 %}
                        list-group-item-warning
                    {% elif eachquestion.status == 4 %}  
                        list-group-item-danger
                    {% endif %}" style="text-overflow:ellipsis;"><div class="col-xs-1">#{{ eachquestion.id }}<br><span class="glyphicon glyphicon-comment" aria-hidden="true" aria-label="comment num"></span> {{ eachquestion.comnum }}</div><div class="col-md-9" style="overflow: hidden; text-overflow: ellipsis; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; height: 40px; margin-right:25px;">{{ eachquestion.title }} - {{ eachquestion.user.name }}</div> <span>{{ eachquestion.lastreply.time }}</span></a>
                {% endfor %}
            </div>  
        </div>
    </td>
    <td >
        <div class="panel panel-primary">
            <div class="panel-heading text-capitalize">{{ eachgroup }} Channel User</div>
            <div class="panel-body list-group">
                {% for eachuser in groupUser %}
                    <a href="/community/user/?q={{ eachuser.id }}" class="list-group-item {% if eachuser.status == None %}
                    {% elif eachuser.status == 1 %}
                        list-group-item-success
                    {% elif eachuser.status == 2 %}
                        list-group-item-info
                    {% elif eachuser.status == 3 %}
                        list-group-item-warning
                    {% elif eachuser.status == 4 %}  
                        list-group-item-danger
                    {% endif %}"><span class="glyphicon glyphicon-hand-right" aria-hidden="true" aria-label="comment num"></span> {{ eachuser.name }}</a>
                {% endfor %}
            </div>  
        </div>
    </td>
    {% else %}
    <td colspan="2" class="text-left">
        <div class="panel panel-info">
        <div class="panel-heading text-capitalize">
            <a href="/community/group/?gname={{ eachgroup }}">{{ eachgroup }}</a>
        </div>
        </div>
    </td>
    {% endif %}
    </tr>
    {% empty %}
    <td style="width: 80%;">
        <div class="panel panel-primary">
            <div class="panel-heading text-capitalize">World Channel <div class="navbar-right"><a href="/community/newquestion/?gname=world" style="color: white; margin-right: 20px;">New Question <span class="glyphicon glyphicon-plus"></span></a></div></div>
            <div class="panel-body list-group">
                {% for eachquestion in questions %}
                    <a href="/community/question/?q={{ eachquestion.id }}" class="list-group-item {% if eachquestion.status == None %}
                    {% elif eachquestion.status == 1 %}
                        list-group-item-success
                    {% elif eachquestion.status == 2 %}
                        list-group-item-info    
                    {% elif eachquestion.status == 3 %}
                        list-group-item-warning
                    {% elif eachquestion.status == 4 %}  
                        list-group-item-danger
                    {% endif %}" style="text-overflow:ellipsis;"><div class="col-xs-1">#{{ eachquestion.id }}<br><span class="glyphicon glyphicon-comment" aria-hidden="true" aria-label="comment num"></span> {{ eachquestion.comnum }}</div><div class="col-md-9" style="overflow: hidden; text-overflow: ellipsis; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; height: 40px; margin-right:25px;">{{ eachquestion.title }}</div> <span>{{ eachquestion.lastreply.time }}</span></a>
                {% endfor %}
            </div>  
        </div>
    </td>
    <td></td>
    {% endfor %}
</table>
</div>

{% endblock main_div %}